<!-- 2021 9.30 做修改 取消扣除界面 -->
<template>
	<app-layout>
		<view class="u-item" v-for="(item, index) in list" :key="index">
			<view class="dir-left-nowrap cross-center main-between">
				<!-- <view class='u-desc'>{{item.desc}}</view> -->
				<view class='u-integral'>+{{item.receive_time}}金币</view>
			</view>
			<view class="dir-left-nowrap cross-center main-between">
				<view class="dir-left-nowrap cross-center souser">
					<image class="avatar" :src="item.user.userInfo.avatar" mode=""></image>
					<view class="name">
						{{item.user.nickname}}
					</view>
				</view>
				<view class="u-info">
					<text>领取时间: {{item.created_at}}</text>
				</view>
			</view>
		</view>
		<view v-if="list.length == 0" class="tip main-center cross-center">暂无数据</view>
	</app-layout>
</template>

<script>
	import {
		mapGetters,
		mapState
	} from "vuex";

	export default {
		data() {
			return {
				page: 1,
				list: [],
				page_count: 1
			}
		},
		computed: {
			...mapState({
				userInfo: state => state.user.info
			}),
			...mapGetters('mallConfig', {
				getTheme: 'getTheme'
			})
		},
		onLoad() {
			this.getList();
		},
		onReachBottom() {
			if (this.page_count >= this.page) {
				this.getList();
			}
		},
		methods: {
			async getList(redpakid) {
				try {
					let formdata = {
						"ismyred": 1
					}
					const res = await this.$request({
						url: this.$api.gcredpak.record + '&page=' + this.page,
						method: 'post',
						data: {
							// page: this.page,
							formdata: JSON.stringify(formdata)
						}
					});
					let {
						code,
						data,
						msg
					} = res;
					if (code === 0) {
						data.list.map(item => {
							return item.created_at = this.$utils.datetime('Y-m-d h:i:s', item.add_time)
						})
						if (this.page !== 1) {
							this.list = this.list.concat(data.list);
						} else {
							this.list = data.list;
							this.page_count = data.pagination.page_count;
						}
						this.page = data.list.length ? this.page + 1 : this.page;
					} else {
						uni.showToast({
							title: msg,
							icon: 'none',
							duration: 1000
						});
					}
				} catch (e) {
					this.$event.on(this.$const.EVENT_USER_LOGIN).then(() => {
						this.getList();
					});
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.u-item {
		font-size: 28upx;
		padding: 36upx 24upx;
		border-bottom: 1upx solid #e2e2e2;
		background-color: #ffffff;
	}

	.u-desc {
		color: #353535;
		margin-bottom: 6upx;
	}

	.u-integral {
		color: #CD9C62;
		// display: inline-block;
	}

	.u-info {
		font-size: 22upx;
		// float: right;
		color: #999999;
	}

	.tip {
		width: 100%;
		color: #999999;
		height: #{500rpx};
	}

	.souser {
		margin-top: 12rpx;
		font-size: 24rpx;

		.avatar {
			height: 24rpx;
			width: 24rpx;
		}

		.name {
			font-size: 24rpx;
			margin-left: 16rpx;
		}
	}
</style>
